package com.example.controller;

import com.example.entity.Elevator;
import com.example.ext.entity.ExtElevator;
import com.example.service.ElevatorService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * Created by youkun on 2017/10/5.
 */
@RestController
public class ElevatorController {
    @Autowired
    private ElevatorService elevatorService;

    @ApiOperation(value = "查询电梯列表的信息",notes = "查询电梯列表的信息")
    @RequestMapping(value="api/elevator/getList",method = RequestMethod.POST)
    Map<String,Object> getElevatorList(@RequestBody ExtElevator extElevator){

        return elevatorService.queryList(extElevator);
    }
    @ApiOperation(value = "查询电梯列表的信息",notes = "查询电梯列表的信息")
    @RequestMapping(value="api/elevator/getMaintList",method = RequestMethod.POST)
    Map<String,Object> getMaintElevatorList(@RequestBody Map<String, Object> extElevator){

        return elevatorService.queryMaintList(extElevator);
    }
    @ApiOperation(value = "查询电梯列表的信息",notes = "查询电梯列表的信息")
    @RequestMapping(value="api/elevator/getJgList",method = RequestMethod.POST)
    Map<String,Object> getJgElevatorList(@RequestBody Map<String, Object> extElevator){

        return elevatorService.queryJgList(extElevator);
    }

    @ApiOperation(value = "添加电梯的信息",notes = "添加电梯的信息")
    @RequestMapping(value="api/elevator/add",method = RequestMethod.POST)
    Map<String,Object> addElevator(@RequestBody Elevator elevator){

        return elevatorService.add(elevator);
    }

    @ApiOperation(value = "修改电梯的信息",notes = "修改电梯的信息")
    @RequestMapping(value="api/elevator/update",method = RequestMethod.POST)
    Map<String,Object> updateElevator(@RequestBody Elevator elevator){

        return elevatorService.update(elevator);
    }

    @ApiOperation(value = "查询某个电梯的信息",notes = "根据用户id获取电梯详细信息")
    @RequestMapping(value="api/elevator/{id}",method = RequestMethod.POST)
    Map<String,Object> findUserFunction(@PathVariable String id) {

        return elevatorService.queryById(id);
    }

    @ApiOperation(value = "查询某个电梯的信息",notes = "根据用户id获取电梯详细信息")
    @RequestMapping(value="api/userElevator/{id}",method = RequestMethod.POST)
    Map<String,Object> findUserElevator(@PathVariable String id) {

        return elevatorService.queryById(id);
    }

    @ApiOperation(value = "删除电梯的信息",notes = "删除电梯的信息")
    @RequestMapping(value="api/elevator/delete",method = RequestMethod.POST)
    Map<String,Object> delete(@RequestBody Map<String, Object> param) {
        List<String> ids = (List<String>)param.get("ids");
        return elevatorService.delete(ids);
    }


    @ApiOperation(value = "导入电梯的信息",notes = "导入电梯的信息")
    @RequestMapping(value="elevator/import",method = RequestMethod.POST)
    Map<String,Object> importElevator(@RequestBody MultipartFile file ,@RequestParam("partyId") String partyId){

        return elevatorService.importElevator(file,partyId);
    }

    @ApiOperation(value = "更新电梯经纬度",notes = "更新电梯经纬度")
    @RequestMapping(value="api/elevator/updateLatLng",method = RequestMethod.POST)
    Map<String,Object> updateLatLng(@RequestBody Map<String, Object> param) {
        return elevatorService.updateLatLng(param);
    }

    @ApiOperation(value = "获取电梯经纬度",notes = "获取电梯经纬度")
    @RequestMapping(value="api/elevator/getLatLng",method = RequestMethod.POST)
    Map<String,Object> getLatLng(@RequestBody Map<String, Object> param) {
        return elevatorService.getLatLng(param);
    }

    @ApiOperation(value = "更新电梯场所",notes = "更新电梯场所")
    @RequestMapping(value="api/elevator/updateElevatorPlace",method = RequestMethod.POST)
    Map<String,Object> updateElevatorPlace(@RequestBody Map<String, Object> param) {
        return elevatorService.updateElevatorPlace(param);
    }

    @ApiOperation(value = "批量更新电梯的安全管理员",notes = "批量更新电梯的安全管理员")
    @RequestMapping(value="api/elevator/updateSafeUser",method = RequestMethod.POST)
    Map<String,Object> updateSafeUser(@RequestBody Map<String, Object> param) {
        return elevatorService.updateSafeUser(param);
    }

    @ApiOperation(value = "查询电梯信息",notes = "根据电梯编号查询电梯信息")
    @RequestMapping(value="api/elevator/getElevatorInfoByNum",method = RequestMethod.POST)
    Map<String,Object> getElevatorInfoByNum(@RequestBody Map<String, Object> param){
        return elevatorService.getElevatorInfoByNum(param);
    }

    @ApiOperation(value = "双随机一公开查询电梯信息",notes = "双随机一公开查询电梯信息")
    @RequestMapping(value="api/elevator/getElevatorList",method = RequestMethod.POST)
    Map<String,Object> getElevatorList(@RequestBody Map<String, Object> param){
        return elevatorService.getElevatorList(param);
    }

    @ApiOperation(value = "按需维保查询电梯台账",notes = "按需维保查询电梯台账")
    @RequestMapping(value="api/elevator/demandMaintGetElevators",method = RequestMethod.POST)
    Map<String,Object> demandMaintGetElevators(@RequestBody ExtElevator extElevator){
        return elevatorService.demandMaintGetElevators(extElevator);
    }

    @ApiOperation(value = "查询电梯台账制造单位",notes = "查询电梯台账制造单位")
    @RequestMapping(value="api/elevator/queryCreateCompanys",method = RequestMethod.POST)
    Map<String,Object> queryCreateCompanys(@RequestBody ExtElevator extElevator){
        return elevatorService.queryCreateCompanys(extElevator);
    }

}
